Skip to content

Conversation

@aguspe
Copy link
Contributor

@aguspe aguspe commented Mar 22, 2025

User description

Motivation and Context

We want our tests to be executed and pass for the BiDi implementation

This PR aims to fix the browser_context and network bidi tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix, Tests


Description

  • Fixed BiDi tests for browser context and network.

  • Updated error handling for unknown types in tests.

  • Improved handling of user prompts in browsing context tests.

  • Added cleanup step to reset driver in network tests.


Changes walkthrough 📝

Relevant files
Tests
browsing_context_spec.rb
Fix and enhance browsing context BiDi tests                           

rb/spec/integration/selenium/webdriver/bidi/browsing_context_spec.rb

  • Fixed error handling for unknown type in tests.
  • Updated user prompt handling with better navigation and validation.
  • Replaced driver with bridge for browsing context initialization.
  • Improved viewport setting and browser context activation tests.
  • +24/-13 
    network_spec.rb
    Enhance network BiDi tests with cleanup                                   

    rb/spec/integration/selenium/webdriver/bidi/network_spec.rb

  • Added cleanup step to reset driver after each test.
  • Ensured intercept addition test is properly scoped.
  • +2/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @aguspe aguspe added the C-rb Ruby Bindings label Mar 22, 2025
    @qodo-merge-pro qodo-merge-pro bot removed the C-rb Ruby Bindings label Mar 22, 2025
    @qodo-merge-pro
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Test Reliability

    The test for unknown type errors now includes an except clause for Firefox. This suggests there might be inconsistent behavior between browsers that should be documented or addressed in the implementation.

    it 'errors on unknown type', except: {browser: :firefox, reason: "Doesn't return the expected error"} do
    Missing Helper Method

    The code uses wait_for_alert and wait_for_no_alert helper methods, but these aren't defined in the visible code. Ensure these helper methods are properly defined elsewhere.

    wait_for_alert
    window = driver.window_handles.first
    browsing_context.handle_user_prompt(window, accept: true, text: 'Hello, world!')
    wait_for_no_alert

    @qodo-merge-pro
    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Standardize alert waiting mechanism

    The test uses wait.until to wait for the alert to appear, but uses a different
    method wait_for_alert in the other test cases. For consistency, use the same
    waiting mechanism across all alert tests.

    rb/spec/integration/selenium/webdriver/bidi/browsing_context_spec.rb [84-95]

     it 'accepts users prompts without text' do
       browsing_context = described_class.new(bridge)
     
       driver.navigate.to url_for('alerts.html')
       driver.find_element(id: 'alert').click
    -  wait.until { driver.switch_to.alert }
    +  wait_for_alert
       window = driver.window_handles.first
       browsing_context.handle_user_prompt(window, accept: true)
       wait_for_no_alert
     
       expect(driver.title).to eq('Testing Alerts')
     end
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly identifies an inconsistency in how alerts are waited for across test cases. Standardizing on the wait_for_alert method improves code consistency and maintainability, making the test suite more uniform and easier to understand.

    Medium
    • More

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant